home *** CD-ROM | disk | FTP | other *** search
/ Singles Flirt Up Your Life! (German) / Singles Flirt Up Your Life.iso / data1.cab / Statemachine / showerChar.lua < prev    next >
Text File  |  2004-01-29  |  7KB  |  264 lines

  1. -- shower character state machine
  2. beginStateMachine()
  3.     
  4.     onEnter(function(msg)
  5.         local shower = getStateObjectFromID(msg.sender);
  6.         storeStateObject("shower", shower);
  7.         storeData("initOutfit", getParent().getOutfit());
  8.         
  9.         if (shower) then
  10.             -- shower does exist
  11.             if (getParent().isOneActionPointLocked(shower)) then
  12.                 -- action point is locked
  13.                 getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  14.                 sendMsg("emoThink", getParent().walkSO);
  15.                 exitStateMachine();
  16.             else
  17.                 getParent().lockActionPoints(shower);
  18.             end
  19.         else
  20.             -- shower does not exist anymore
  21.             getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  22.             sendMsg("emoThink", getParent().walkSO);
  23.             exitStateMachine();
  24.         end
  25.         
  26.         freeHands(getParent());
  27.         
  28.         
  29.     end )
  30.     
  31.     onExit(function(msg)
  32. --        local shower = retrieveStateObject("shower");
  33. --        getParent().stopAllActivities(shower);
  34. --        getParent().unlockActionPoints(shower);
  35. --        removeStateObject("shower");
  36.         
  37.         unlockAll("shower");        
  38.     end )
  39.     
  40.     
  41.     onMsg("startShowerLoopSound", function(msg)
  42.         print("startShowerLoopSound");
  43.         local shower = retrieveStateObject("shower");
  44.         shower.loopSound("showerLoop");                    
  45.     end )
  46.     
  47.     
  48.     -- undress outside the shower
  49.     state("undressOutside")
  50.     
  51.         onEnter(function(msg)
  52.             print("undressOutside onEnter");
  53.         
  54.             local character = getParent();        
  55.             local other, result = getDisturbingChar(character, "showNaked");
  56.             if (other) then
  57.                 exitStateMachine();
  58.                 character.setEmoticon(EMOTICON_SHY, EMOTICON_DELAY);
  59.                 other.sendMsg("emoShameChar", character.walkSO);        
  60.                 return    
  61.             end;
  62.         
  63.         
  64. --            local character = getParent();
  65. --            local others = character.getCharactersInRoom();
  66. --                    
  67. --            for c = 1, getn(others) do
  68. --                local other = others[c];
  69. --                --print("checkShyness other found");
  70. --                if (not activityPossible(character, "showInUnderwear", other)) then
  71. --                    exitStateMachine();
  72. --                    --print("checkShyness sendMsg emoShame");
  73. --                    character.setEmoticon(EMOTICON_SHY, EMOTICON_DELAY);
  74. --                    other.sendMsg("emoShameChar", character.walkSO);        
  75. --                    return    
  76. --                end;
  77. --            end;
  78.                 
  79.         
  80.             --startAnimation("ausziehen2");
  81.             startAnimation(getChangeOutfitAnim(getParent()));
  82.             sendDelayedMsgThis("underwear", 1600);
  83.  
  84.             local shower = retrieveStateObject("shower");
  85.             shower.playSound("showerFadein");
  86.             sendDelayedMsg("startShowerLoopSound", this, 4100);                        
  87.             shower.setChildEnable("damp", true);
  88.         end )
  89.         
  90.         onMsg("underwear", function(msg)
  91.             getParent().changeOutfit(UNDERWEAR);
  92.         end )
  93.         
  94. --        onMsg("startLoopSound", function(msg)
  95. --            print("undressOutside startLoopSound");
  96. --            local shower = retrieveStateObject("shower");
  97. --            shower.loopSound("showerLoop");                    
  98. --        end )
  99.         
  100.     
  101.         onMsg("end", function(msg)
  102.             print("undressOutside end");
  103.             if testCancel() then
  104.                 local shower = retrieveStateObject("shower");
  105.                 shower.stopSound("showerLoop");
  106.                 shower.playSound("showerFadeout");            
  107.                 shower.setChildEnable("damp", false);
  108.                 local initOutfit = retrieveData("initOutfit");        
  109.                 getParent().changeOutfit(initOutfit);
  110.                 exitStateMachine();
  111.             else
  112.                 setState("enterShower");
  113.                 sendDelayedMsgThis("act", 5000);
  114.             end
  115.         end )    
  116.  
  117.     
  118.     -- enter the shower
  119.     state("enterShower")
  120.     
  121.         onEnter(function(msg)
  122.             startAnimation("enterShowerElaine");
  123.             local shower = retrieveStateObject("shower");
  124.             --shower.playSound("enterShower");
  125.             sendDelayedMsgThis("playEnterShowerSound", 500);
  126.             --shower.startAnimation("showerDesignEnter");
  127.             playShowerAnim(shower, "Enter");
  128.  
  129.         end )
  130.         
  131.         onMsg("playEnterShowerSound", function(msg)
  132.             local shower = retrieveStateObject("shower");
  133.             shower.playSound("enterShower");                    
  134.         end )
  135.         
  136.         
  137.     
  138.         onMsg("end", function(msg)
  139.             if testCancel() then
  140.                 setState("exitShower")
  141.             else
  142.                 setState("undressShower");
  143.             end
  144.         end )
  145.     
  146.     -- undress in the shower
  147.     state("undressShower")
  148.     
  149.         onEnter(function(msg)
  150.             local shower = retrieveStateObject("shower");
  151.             local takeShower = getParent().startActivity("shower", shower);
  152.             -- storeData("takeShower", takeShower);
  153.             local takeShowerLength, scale = getActivityLength(takeShower);
  154.             storeData("takeShowerLength", takeShowerLength);
  155.             
  156.             startAnimation("undressShowerElaine");
  157.             sendDelayedMsgThis("hideCloth", 4000);
  158.         end )
  159.         
  160.         onMsg("hideCloth", function(msg)
  161.             getParent().changeOutfit(NOTHING);
  162.             --getParent().enableBlend(true);
  163.             --print("outfit NOTHING", getParent().getOutfit());
  164.         end )
  165.     
  166.         onMsg("end", function(msg)
  167.             if testCancel() then
  168.                 setState("exitShower")
  169.             else
  170.                 setState("shower");
  171.                 sendDelayedMsgThis("act", 5000);
  172.             end
  173.         end )    
  174.     
  175.     -- take a shower
  176.     state("shower")
  177.     
  178.         onEnter(function(msg)
  179.             --local shower = retrieveStateObject("shower");
  180.             --shower = getParent().startActivity("shower", shower);
  181.             
  182.             -- local takeShower = retrieveData("takeShower");            
  183.             -- local length, scale = getActivityLength(takeShower);
  184.             
  185.             local length = retrieveData("takeShowerLength");
  186.             
  187.             startAnimation("showerElaine");
  188.             -- to make quick abort on queue            
  189.             sendDelayedMsgThis("endShower", length);
  190.             --this.actionComplete();    
  191.                     
  192.             sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
  193.         end )
  194.                 
  195.         onMsg("queue", function(msg)
  196.             sendMsgThis("endShower");
  197.         end )
  198.         
  199.         onMsg("endShower", function(msg)
  200.             print("endShower")
  201.             local shower = retrieveStateObject("shower");
  202.             shower.stopSound("showerLoop");
  203.             shower.playSound("showerFadeout");            
  204.             getParent().stopAllActivities(shower);
  205.             setState("exitShower")
  206.         end )
  207.                     
  208.         onMsg("testCancel", function(msg)
  209.             if testCancel() or (not this.getParent().getCurrentActivityGain()) then
  210.                 sendMsgThis("endShower");
  211.             else
  212.                 sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
  213.             end
  214.         end )
  215.  
  216.         onMsg("end", function(msg)
  217.             if testCancel() then
  218.                 sendMsgThis("endShower");
  219.             else
  220.                 startAnimation("showerElaine");
  221.             end
  222.         end )    
  223.         
  224.     -- exit the shower
  225.     state("exitShower")
  226.     
  227.         onEnter(function(msg)
  228.             -- show clothes
  229.             startAnimation("exitShowerElaine");
  230.             
  231.             local shower = retrieveStateObject("shower");
  232.             shower.stopSound("showerLoop");
  233.             playShowerAnim(shower, "Exit");
  234.             --shower.startAnimation("showerDesignEnter", -1);
  235.             --shower.startAnimation("showerDesignExit");
  236.             sendDelayedMsgThis("playTakeTowelSound", 500);
  237.             sendDelayedMsgThis("showTowel", 3800);
  238.             sendDelayedMsgThis("playExitSound", 4440);
  239.             
  240.         end )
  241.         
  242.         onMsg("playTakeTowelSound", function(msg)
  243.             local shower = retrieveStateObject("shower");
  244.             shower.playSound("showerTakeTowel");            
  245.         end )
  246.         
  247.         onMsg("showTowel", function(msg)
  248.             getParent().changeOutfit(TOWEL);
  249.             --getParent().enableBlend(false);
  250.         end )
  251.         
  252.  
  253.         onMsg("playExitSound", function(msg)
  254.             local shower = retrieveStateObject("shower");
  255.             shower.playSound("showerExit");    
  256.             shower.setChildEnable("damp", false);        
  257.         end )
  258.         
  259.     
  260.         onMsg("end", function(msg)
  261.             exitStateMachine();
  262.         end )    
  263.             
  264. endStateMachine()